﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;


namespace FAP.DataAccess.BLL
{
    public class fieldformat
    {
        public int id { get; set; }
        public string ten { get; set; }
        public bool isdeleted { get; set; }
        //public List<chitietbuocthuchien> chitietbuocthuchiens { get { return chitietbuocthuchien.chitietbuocthuchienSelectRowByForeignKey_fieldformatid(id); } }

        #region fieldformatSelectAll
        public static List<fieldformat> fieldformatSelectAll()
        {
            IDataReader dr = FAP.DataAccess.DAL.fieldformatSelectAll();
            List<fieldformat> fieldformatList = new List<fieldformat>();
            while (dr.Read())
            {
                fieldformat myfieldformat = new fieldformat
                {
                    id = !dr.IsDBNull(dr.GetOrdinal("id")) ? (int)dr["id"] : 0,
                    ten = !dr.IsDBNull(dr.GetOrdinal("ten")) ? (string)dr["ten"] : null,
                    isdeleted = !dr.IsDBNull(dr.GetOrdinal("isdeleted")) ? (bool)dr["isdeleted"] : false
                };
                fieldformatList.Add(myfieldformat);
            }
            dr.Close();
            dr.Dispose();
            return fieldformatList;
        }
        #endregion

        #region fieldformatSelectRow
        public static fieldformat fieldformatSelectRow(int id)
        {
            IDataReader dr = FAP.DataAccess.DAL.fieldformatSelectRow(id);
            fieldformat fieldformat = null;

            if (dr.Read())
            {
                fieldformat = new fieldformat
                {
                    id = !dr.IsDBNull(dr.GetOrdinal("id")) ? (int)dr["id"] : 0,
                    ten = !dr.IsDBNull(dr.GetOrdinal("ten")) ? (string)dr["ten"] : null,
                    isdeleted = !dr.IsDBNull(dr.GetOrdinal("isdeleted")) ? (bool)dr["isdeleted"] : false,

                };
            }
            dr.Close();
            dr.Dispose();
            return fieldformat;
        }
        #endregion

        #region fieldformatInsertRow
        public static void fieldformatInsertRow(string ten, bool isdeleted)
        {
            FAP.DataAccess.DAL.fieldformatInsertRow(ten, isdeleted);
        }
        #endregion

        #region fieldformatUpdateRow
        public static void fieldformatUpdateRow(int id, string ten, bool isdeleted)
        {
            FAP.DataAccess.DAL.fieldformatUpdateRow(id, ten, isdeleted);
        }
        #endregion

        #region fieldformatDeleteRow
        public static void fieldformatDeleteRow(int id)
        {
            FAP.DataAccess.DAL.fieldformatDeleteRow(id);
        }
        #endregion
    }
}